<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS DOM2 事件机制</title>
    <style>
        #parent{
            background-color: blue;
            width: 200px;
            height: 200px;
        }
        #child{
            background-color: red;
            width: 100px;
            height: 100px;

        }
    </style>
</head>
<body>
    <div id="parent">
        <div id="child">

        </div>
    </div>
    <script>
        //html css js 要各司其职 
        //行内样式要少用
        //js事件也不要用 DOM0 html js会耦合在一起
        //DOM 0 和 DOM 2 混用的话 不方便维护
        //addEventListener 统一用 useCapture能力
        document.getElementById('parent')
        .addEventListener('click',function(event){
            console.log('1111');
            
        },false)
        document.getElementById('child')
        .addEventListener('click',function(event){
            console.log('2222');
            
        },false)
    </script>
</body>
</html>